import axios from 'axios'

axios.defaults = {
    baseURL: '/api',
    timeout: 10000
}


const token = localStorage.getItem('token')
const request = {
    async get(url, params) {
        let result = await axios({
            method: 'get',
            url,
            params,
            headers: { // 设置请求头
                token
            }
        })
        return result
    },
    async post(url, data) {
        let result = await axios({
            method: 'post',
            url,
            data,
            headers: { // 设置请求头
                token
            }
        })
        return result
    },
}

export default request
